#include "base.h"
#include "types.h"
#include <string>
#include <boost/filesystem.hpp>
using namespace std;
using namespace boost::filesystem;

void SetConsoleColor(uint foreground, uint background)
{
	HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
	word attrib = (foreground & 0xF) | ((background & 0xF) << 4);
	SetConsoleTextAttribute(consoleHandle, attrib);
}
string GetWorkingDir()
{
	return current_path().string();
}
bool glErrorCheck()
{
	GLenum err = glGetError();
	if(err != GL_NO_ERROR)
	{
		const unsigned char *errStr = gluErrorString(err);
		if(errStr == NULL)
		{
			RError(cout << "Unknown gl render error: " << hex << err);
		}else{
			RError(cout << errStr);
		}
		return true;
	}
	return false;
}
wstring MakeUnicodeString(const string &src)
{
	uint strLen = src.length();
	const char *srcStr = src.c_str();
	wchar_t *dstStr = new wchar_t[strLen+1];
	memset(dstStr, 0, sizeof(wchar_t)*(strLen+1));
	mbstowcs(dstStr, srcStr, strLen+1);

	wstring ret(dstStr);
	delete[] dstStr;

	return ret;
}